<template>
    <div class="ep-content">
        <div class="ep-input-content" style="margin-bottom:20px;">
            <label><i class="iconfont iconzhengjian"></i></label>
            <input v-model="username" placeholder="请输入身份号码"/>
        </div>
        <div class="ep-input-content">
            <label><i class="iconfont iconzhengjian"></i></label>
            <input v-model="password" placeholder="请输入登录密码"/>
        </div>
        <div class="inputbtn"><mt-button type="primary" @click="login" style="width:100%;">登 录</mt-button></div>
        <div class="ep-tool">
            <a>忘记密码</a>
            <a>立即注册</a>
        </div>
    </div>
</template>

<script type="es6">
    export default {
        data() {
            return {
                username:'',
                password:''
            }
        },
        created() {
        },
        methods: {

    login() { // 登录
    let that=this;
      this.loading = true;
      let params = {
        userName: "user1",
        pwd:"123"
      };
      
      // 调用接口
     this.$http.get("https://www.easy-mock.com/mock/5d54c7d3b0d15e6c4a8ca44b/example/userinfo",params).then(res=>{
       
       if (res.code === 0) {
          let userInfo = {
            'id': res.rows.aac002,
            'name': res.rows.aac003,
            'jobname':res.rows.aca112,
            'timestamp': new Date().getTime()
          }
         window.sessionStorage.setItem("userInfo", JSON.stringify(userInfo));// 将用户信息存到localStorage中
         sessionStorage.setItem("token", "ffcd41f5-8abf-481e-8978-b6bd4ef17cea");
          that.$router.replace({path: '/'}); // 登录成功跳转
        } else {
          this.loading = false;
          this.$message.error(res.msg);// elementUI消息提示
        }
      });
      
    
  }

        }
    }
    document.body.style.background="#fff";

</script>

<style lang="less" scoped>
    .ep-content{
        padding: .2rem;
        .inputbtn{ text-align: center; margin-top: .2rem;}
    }
    .ep-tool{
        display: flex;
        justify-content: space-between;
        margin-top:40px;
    }
    .ep-input-content{
        display: flex;
        border:1px solid #e1e1e1;
        label{
            width:40px;
            line-height:40px;
            text-align: center;
            i{
                font-size:22px;
                color:#beccde;
            }
        }
        input{
            flex:1;
            border:none;
            height:40px;
            font-size:14px;
        }
    }


</style>
